<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            font-family: 'Open Sans', sans-serif;
            background-color: #f9fafb;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            margin: 0;
        }

        #container {
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
            width: 400px;
        }

        form {
            max-width: 400px;
            margin: 10px auto;
            padding: 16px;
        }

        label,
        select {
            display: block;
            margin: 10px 0;
        }

        select {
            width: 100%;
            font-size: 1em;
            padding: 5px;
        }

        button {
            box-sizing: border-box;
            width: 100%;
            padding: 3%;
            background: #007bff;
            border-bottom: 2px solid #007bff;
            border-top-style: none;
            border-right-style: none;
            border-left-style: none;
            color: #fff;
            font-size: 14px;
        }

        button:hover {
            background: #0069d9;
            cursor: pointer;
        }

        form input[type='text'] {
            outline: none;
            box-sizing: border-box;
            width: 100%;
            background: #fff;
            margin-bottom: 2%;
            border: 1px solid #ccc;
            padding: 3%;
            color: #555;
            font-size: 1em;
        }

        form input[type='text']:focus {
            box-shadow: 0 0 5px #f0db4f;
            padding: 3%;
            border: 1px solid #f0db4f;
        }
    </style>
</head>

<body>
    <div id="container">
        <form autocomplete="off">
            <label for="framework">Framework:</label>
            <input type="text" id="framework" placeholder="Enter a framework">

            <button id="btnAdd">Add</button>

            <label for="list">Framework List:</label>
            <select id="list" name="list" multiple>

            </select>
            <button id="btnRemove">Remove Selected Framework</button>
        </form>
    </div>

    <script>
        const btnAdd = document.querySelector('#btnAdd');
        const btnRemove = document.querySelector('#btnRemove');
        const listbox = document.querySelector('#list');
        const framework = document.querySelector('#framework');

        btnAdd.onclick = (e) => {
            e.preventDefault();

            // validate the option
            if (framework.value == '') {
                alert('Please enter the name.');
                return;
            }
            // create a new option
            const option = new Option(framework.value, framework.value);
            // add it to the list
            listbox.add(option, undefined);

            // reset the value of the input
            framework.value = '';
            framework.focus();
        };

        // remove selected option
        btnRemove.onclick = (e) => {
            e.preventDefault();

            // save the selected options
            let selected = [];

            for (let i = 0; i < listbox.options.length; i++) {
                selected[i] = listbox.options[i].selected;
            }

            // remove all selected option
            let index = listbox.options.length;
            while (index--) {
                if (selected[index]) {
                    listbox.remove(index);
                }
            }
        };

    </script>
</body>

</html>